<script setup lang="ts">
import {useRoute, useRouter} from "vue-router";
import {ref} from "vue";
import routes from "../config/routes.ts";

const router = useRouter()
const route = useRoute()
const title = ref<string>('伙伴匹配')

router.beforeEach((to) => {
  const route = routes.find((route) => {
    return to.path == route.path;
  })
  title.value = route?.title;
})

const onClickLeft = () => {
  router.back()
}
const onClickRight = () => {
  router.push('/search');
}
</script>

<template>
  <van-nav-bar fixed safe-area-inset-top
      :title="title"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
  >
    <template #right>
      <van-icon name="search" size="18"/>
    </template>
  </van-nav-bar>
  <div id="content">
    <router-view />
  </div>
  <van-tabbar route>
    <van-tabbar-item to="/" icon="home-o" name="index">主页</van-tabbar-item>
    <van-tabbar-item to="/team" icon="search" name="team">队伍</van-tabbar-item>
    <van-tabbar-item to="/user" icon="friends-o" name="user">个人</van-tabbar-item>
  </van-tabbar>
</template>

<style scoped>
#content {
  padding-top: 50px;
  padding-bottom: 50px;
}
</style>
